﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BAL;
namespace QuanLyTiemNET_DEV_LINQ
{
    public partial class XtraFormThemMayTinh : DevExpress.XtraEditors.XtraForm
    {
        public XtraFormThemMayTinh()
        {
            InitializeComponent();
        }

        private void XtraFormThemMayTinh_Load(object sender, EventArgs e)
        {
            
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            txtMaMay.ResetText();
           
            
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string err = null;
            try
            {
                if (BAL_MAYTINH.ThemMT(ref err, txtMaMay.Text, FrmPhongMay.maPhong))
                {
                    MessageBox.Show("Thêm thành công!!!!");
                    this.Close();
                }
                    
                else
                {
                    MessageBox.Show("Lỗi: " + err);
                    
                    txtMaMay.ResetText();
                }
                   
                
            }
            catch(Exception e1)
            {
                MessageBox.Show(e1.Message);
                txtMaMay.ResetText();
            }
        }
    }
}